<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="48">
          <a-col :md="8" :sm="24">
            <a-form-item label="流程标题">
              <a-input placeholder="标题" v-model="queryParam.subject"/>
            </a-form-item>
          </a-col>
          <a-col :md="8" :sm="24">
            <a-form-item label="流程名称">
              <a-input placeholder="名称" v-model="queryParam.name"/>
            </a-form-item>
          </a-col>
          <a-col :md="8" :sm="24">
            <a-button @click="() => {this.queryPage()}" type="primary">查询</a-button>
            <a-button @click="() => queryParam = {}" style="margin-left: 8px">重置</a-button>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <s-table
      bordered
      ref="table"
      :alert="alert"
      :data="loadData"
      :columns="columns"
      :rowKey="record => record.id"
      :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
    >
      <template v-slot:action="record">
        <span >
          <a-popconfirm title="是否删除该流程" @confirm="remove(record.id)" okText="是" cancelText="否">
            <a-icon slot="icon" type="question-circle-o" style="color: red" />
            <a href="javascript:" >删除</a>
            <a-divider type="vertical" />
          </a-popconfirm>
        </span>
      </template>
    </s-table>

  </a-card>
</template>

<script>
import { fetchList } from '@/api/process/instance'
import { TableMixin } from '@/mixins/TableMixin'
export default {
  name: 'InstanceList',
  components: {

  },
  mixins: [TableMixin],
  data () {
    return {
      columns: [
        {
          title: '序号',
          customRender: (text, record, index) => {
            return (
              <div>
                {index + 1}
              </div>
            )
          }
        }, {
          title: '名称',
          dataIndex: 'name'
        }, {
          title: '标题',
          dataIndex: 'subject'
        }, {
          title: '流程Key',
          dataIndex: 'defKey'
        }, {
          title: '激活状态',
          dataIndex: 'activate',
          customRender: (text, record, index) => {
            return text ? '是' : '否'
          }
        }, {
          title: '运行状态状态',
          dataIndex: 'status'
        }, {
          title: '操作',
          width: '200px',

          scopedSlots: { customRender: 'action' }
        }
      ],
      loadData: parameter => {
        return fetchList(
          Object.assign(parameter, this.queryParam)
        ).then(res => {
          return res.data
        })
      }
    }
  },
  methods: {
  }
}
</script>

<style scoped>

</style>
